export default function error() {
    // 捕获资源加载的错误
    window.addEventListener("error",function (e) {
       if(!e.target) {
            return;
       }
       const target = e.target;
       if(target.src || target.href) {
            const url = target.src || target.href;
           const reportData = {
                type: 'error',
                subType: 'resource',
                url,
                html: target.outerHTML,
                pageUrl: window.location.href,
                paths: e.path
                
           }
       }
       // 上报数据todo

    },true)
    // 捕获js错误
    window.onerror = function (msg, url, line, col, error) {
        const reportData = {
            type: 'error',
            subType: 'js',
            msg,
            url,
            lineNo,
            columnNo,
            stack: error.stack,
            pageUrl: window.location.href,
            startTime: performance.now(),
        }
        // 上报数据todo
    }
    // 捕获promise错误，async await
    window.addEventListener("unhandledrejection",function (e) {
        const reportData = {
            type: 'error',
            subType: 'promise',
            reason: e.reason?.stack,
            pageUrl: window.location.href,
            startTime: e.timeStamp,
        }
    },true)
    // 上报数据todo
}